package com.sailmi.gateway.session;
import java.time.Duration;


import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.server.WebSession;


@Service
public class SessionGatewayFilterFactory extends AbstractGatewayFilterFactory<Object> {
	@Override
	public GatewayFilter apply(Object config) {

		return (exchange, chain) -> {
			exchange.getSession().doOnNext(res->res.setMaxIdleTime(Duration.ofDays(10))).subscribe();
			return chain.filter(exchange);
		};
	}

}
